<template>
  <!-- 黑名单新增-->
  <el-dialog
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <el-form ref="addForm" :model="addForm" :rules="rules" label-width="110px">
      <!--黑名单新增-->
      <el-card class="form-card blackList-card">
        <div slot="header" class="label-header-msg">
          <span></span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="类型" prop="fileType">
              <el-select
                v-model="addForm.fileType"
                placeholder="类型"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dictMap.FILE_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="黑名单名称" prop="blacklistName">
              <el-input
                v-model="addForm.blacklistName"
                placeholder="黑名单名称"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="黑名单备注" prop="remarks">
              <el-input
                v-model="addForm.remarks"
                placeholder="黑名单备注"
                type="textarea"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">提 交</el-button>
      <el-button type="primary" @click="reset">重 置</el-button>
      <el-button @click="cancel">关 闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { blackListAdd} from "@/api/cnaps/bizMng/blackList.js";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "blackListAddDialog",
  mixins: [listPageMixin],
  components: {

  },
  data() {
    return {
      title: "",
      // 是否显示弹出层
      openState: false,
      // 字段可编辑控制

      //数据字典
      searchFormDictList: [
       "DATE_SOURCE",
       "FILE_TYPE"
      ],
      // 表单参数
      addForm:{},
      // 表单校验
      rules: {
        fileType: [{ required: true, message: "请选择类型", trigger: "blur" }],
        blacklistName: [{ required: true, message: "请输入黑名单名称", trigger: "blur" }],
        remarks: [{ required: true, message: "请输入黑名单备注", trigger: "blur" }],
      },
      opButtonList: () => {
        return [
        ];
      },
    };
  },
  mounted() {
  },
  methods: {
    // 表单重置
    reset() {
      this.resetForm("addForm");
      this.$set(this, "addForm", {});
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(_ => {
          this.reset();
          done();
        })
        .catch(_ => {});
    },
    show() {
      this.title = "黑名单新增";
      this.openState = true;
    },

    /** TODO提交按钮 */
    submitForm: function() {
      this.$refs["addForm"].validate(valid => {
        if (valid) {
          this.submit();
        }
      });
    },

    submit() {
      blackListAdd(this.addForm).then(res => {
        if (res.code === 'S') {
          this.msgSuccess("提交成功");
          this.cancel();
        }
      });
    },

    cancel() {
      this.openState = false;
      this.reset();
      this.$emit("editComplete", true);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
